package com.flow.asyncflow.test;


import com.flow.asyncflow.core.entity.core.AsyncFlowResponse;
import com.flow.asyncflow.test.AsyncFlow.Context.plusasyncflowtest.PlusAsyncFlowTestContext;
import com.flow.asyncflow.test.AsyncFlow.Enum.plusasyncflowtest.PlusAsyncFlowTestOperatorEnum;
import com.flow.asyncflow.test.AsyncFlow.Model.plusasyncflowtest.PlusAsyncFlowTestRequest;
import com.flow.asyncflow.test.AsyncFlow.Model.plusasyncflowtest.PlusAsyncFlowTestResponse;
import com.flow.asyncflow.test.Manager.asyncflowtest.PlusAsyncFlowTestManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StopWatch;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDateTime;

@RestController
@RequestMapping("/AsyncFlowTest")
public class AsyncFlowTestController {


    @Autowired
    private PlusAsyncFlowTestManager plusAsyncFlowTestManager;

    @GetMapping("Test")
    public void test() {
        StopWatch sw = new StopWatch();
        sw.start("第一步");
        PlusAsyncFlowTestRequest request = new PlusAsyncFlowTestRequest("请求参数");
        request.setBusinessSerialId(LocalDateTime.now().toString());
        request.setOperateName("测试");
        request.setOperateNo("110");
        request.setSourceDes("测试请求");
        String testStr = "{\"com.flow.asyncflow.test.AsyncFlow.Model.plusasyncflowtest.PlusAsyncFlowTestRequest\":{\"businessSerialId\":\"2022-06-06T17:37:28.246\",\"operateName\":\"测试\",\"operateNo\":\"110\",\"params\":{},\"req\":\"请求参数\",\"reqTypeEnumMsg\":\"升级版\",\"reqTypeEnumName\":\"PlusAsyncFlowTest\",\"requesterTime\":\"2022-06-06T17:37:28.246\",\"sourceDes\":\"测试请求\"},\"com.flow.asyncflow.test.AsyncFlow.Context.plusasyncflowtest.PlusAsyncFlowTestContext\":{\"asyncBusinessLogEntityList\":[],\"asyncFlowNodeDetailLogEntityList\":[],\"asyncFlowNodeLogEntityList\":[],\"dataSourceMap\":{},\"executeSQLs\":[]},\"com.flow.asyncflow.core.entity.core.AsyncFlowRequest\":{\"businessSerialId\":\"2022-06-06T17:37:28.246\",\"operateName\":\"测试\",\"operateNo\":\"110\",\"params\":{},\"reqTypeEnumMsg\":\"升级版\",\"reqTypeEnumName\":\"PlusAsyncFlowTest\",\"requesterTime\":\"2022-06-06T17:37:28.246\",\"sourceDes\":\"测试请求\"},\"com.flow.asyncflow.test.AsyncFlow.Model.testasyncflow.Test_2_GetDataEntity.List\":[{\"name\":\"测试查询2_1\"},{\"name\":\"测试查询2_2\"}],\"com.flow.asyncflow.test.AsyncFlow.Model.plusasyncflowtest.PlusAsyncFlowTestResponse\":{\"code\":0},\"com.flow.asyncflow.test.AsyncFlow.Enum.plusasyncflowtest.PlusAsyncFlowTestOperatorEnum\":\"PlusAsyncFlowTest\",\"com.flow.asyncflow.test.AsyncFlow.Model.testasyncflow.Test_1_GetDataEntity\":{\"name\":\"测试查询1\"}}";
        //request.getParams().put("TESTStr",testStr);
        PlusAsyncFlowTestResponse response ;
        PlusAsyncFlowTestOperatorEnum plusAsyncFlowTestOperatorEnum = PlusAsyncFlowTestOperatorEnum.PlusAsyncFlowTest;

        sw.stop();
        long s1 = sw.getTotalTimeMillis();
        sw.start("第二步");
        request.setReqTypeEnumName("ccc");
        response = plusAsyncFlowTestManager.exec(request, PlusAsyncFlowTestOperatorEnum.PlusAsyncFlowTest, PlusAsyncFlowTestResponse.class, PlusAsyncFlowTestContext.class);

        sw.stop();
        long s2 = sw.getTotalTimeMillis();
        //response=asyncFlowPlusResponse.getRes();
        //   testAsyncFlowManager.managerExec(new TestAsyncFlowRequest("请求参数"), PlusAsyncFlowTestOperatorEnum.PlusAsyncFlowTest);
        System.out.println(s1 + "####" + s2);

    }
}
